/*
 * Copyright 2011 J. Auer, J. Andert, F.-J. Jendrusch, U. Celebi
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.fuberlin.replication.application.android.communication.wifi;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import de.fuberlin.replication.R;

/**
 * WiFi device list activity.
 */
public class WiFiEnterHostActivity extends Activity {
	/** Activity result intent extra name for the entered host. */
	public static final String EXTRA_HOST = "de.fuberlin.replication.application.android.communication.wifi.EXTRA_HOST";

	/** Host text. */
	EditText host;

	/** Connect button. */
	Button connect;

	private final View.OnClickListener buttonOkOnClickListener = new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			Intent intent = new Intent();
			intent.putExtra(EXTRA_HOST, host.getText().toString());

			setResult(Activity.RESULT_OK, intent);

			finish();
		}
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setResult(Activity.RESULT_CANCELED);

		requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
		setContentView(R.layout.wifi_enter_host);

		host = (EditText) findViewById(R.id.wifi_text_host);

		connect = (Button) findViewById(R.id.wifi_button_connect);
		connect.setOnClickListener(buttonOkOnClickListener);
	}
}
